import '../../util/_base_export.dart';
import '../../util/_view_export.dart';

import '../order/screen_home.dart';
import '../order/screen_history_main.dart';
import '../order/screen_cart.dart';
import '../account/screen_main.dart';
import '../referal/screen_main.dart';
import '../login/page_signin.dart';
import '../menu/screen_home.dart';
import '../../blocs/product.dart';

// import '../../blocs/home_screen.dart';
// import '../../blocs/wallet_list.dart';

class AppMainView extends StatefulWidget {
  AppMainView({Key? key}) : super(key: key);

  @override
  _AppMainViewState createState() => _AppMainViewState();
}

class _AppMainViewState extends State<AppMainView> {
  int _selectedIndex = 0;
  static const TextStyle optionStyle =
      TextStyle(fontSize: 30, fontWeight: FontWeight.bold);
  static List<Widget> _widgetOptions = <Widget>[
    OrderHomeScreen(),
    ReferalMainScreen(),
    OrderHistoryMainScreen(),
    AccountMainScreen(),
  ];

  void _onItemTapped(int index) {
    setState(() {
      AppSession.bottomIndex = index;
      // _selectedIndex = index;
    });
  }

  @override
  Widget build(BuildContext context) {
    _selectedIndex = AppSession.bottomIndex;
    return Scaffold(
      body: Container(
        constraints: BoxConstraints.expand(),
        child: _widgetOptions.elementAt(_selectedIndex),
      ),
      bottomNavigationBar: BottomNavigationBar(
        items: <BottomNavigationBarItem>[
          BottomNavigationBarItem(
            activeIcon: Image.asset('assets/main/Tab_icon_home_active.png'),
            icon: Image.asset('assets/main/Tab_icon_home_deactive.png'),
            label: AppText.text['main_tab_home'],
          ),
          BottomNavigationBarItem(
            activeIcon: Image.asset('assets/main/Tab_icon_money_active.png'),
            icon: Image.asset('assets/main/Tab_icon_money_deactive.png'),
            label: AppText.text['main_tab_money'],
          ),
          BottomNavigationBarItem(
            activeIcon: Image.asset('assets/main/Tab_icon_orders_active.png'),
            icon: Image.asset('assets/main/Tab_icon_orders_deactive.png'),
            label: AppText.text['main_tab_history'],
          ),
          BottomNavigationBarItem(
            activeIcon: Image.asset('assets/main/Tab_icon_profile_active.png'),
            icon: Image.asset('assets/main/Tab_icon_profile_deactive.png'),
            label: AppText.text['main_tab_account'],
          ),
        ],
        currentIndex: _selectedIndex,
        backgroundColor: AppColor.bgBottomBar,
        selectedItemColor: AppColor.yellowMain,
        unselectedItemColor: AppColor.textBottomBar,
        onTap: _onItemTapped,
      ),
    );
  }
}
